package cn.yl.pay.service.mapper;

import cn.yl.pay.service.entity.PayOrderRecord;
import com.alibaba.fastjson.JSON;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.utils.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class RabbitmqMapper {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendWork() {
        for (int i = 0; i < 10; i++) {
            rabbitTemplate.convertAndSend("pay_order_record_work", "测试work模型: " + i);
        }
    }

    public void sendPayOrderRecord(PayOrderRecord payOrderRecord){
        String payOrderRecordString = JSON.toJSON(payOrderRecord).toString();
        rabbitTemplate.convertAndSend("pay_order_record_work",payOrderRecordString);
    }
}
